package com.tanhua.app.interceptor;

import com.tanhua.model.pojo.User;

public class UserHolder {

    private static ThreadLocal<User> userThreadLocal = new ThreadLocal<>();


    //设置用户
    public static void setUser(User user) {
        userThreadLocal.set(user);
    }

    //获取用户
    public static User getUser() {
        return userThreadLocal.get();
    }

    //获取用户id
    public static Long getUserId() {
        return userThreadLocal.get().getId();
    }

    //获取用户电话
    public static String getMobile() {
        return userThreadLocal.get().getMobile();
    }

    //清理ThreadLocal的数据
    public static void remove() {
        userThreadLocal.remove();
    }
}
